package co.baiku.boot.core.orm.config;

import co.baiku.boot.common.tools.IdWorker;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnProperty(value = "ajavaer.orm.id-generator", havingValue = "snowflake")
public class SnowflakeIdGenerator implements IdentifierGenerator {

    @Override
    public Long nextId(Object entity) {
        return IdWorker.getInstance().nextId();
    }
}